cmake_minimum_required(VERSION 3.16)
project(mimsclient VERSION 0.1 LANGUAGES CXX)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets Protobuf Network WebSockets)


qt_standard_project_setup()

file(GLOB PB_FILES "./proto/*.proto")   # 相当于定义变量

set(CMAKE_AUTOMOC ON)    # 自动处理Qt的moc
set(CMAKE_AUTORCC ON)    # 自动处理资源文件
set(CMAKE_AUTOUIC ON)    # 自动处理UI文件

qt_add_executable(mimsclient
    WIN32 MACOSX_BUNDLE
    main.cpp
    mainwidget.cpp
    mainwidget.h
    mainwidget.ui
    model/data.h


    reource.qrc
    sessionfriendarea.h sessionfriendarea.cpp
    debug.h
    messageshowarea.h messageshowarea.cpp
    messageeditarea.h messageeditarea.cpp

    selfinfowidget.h selfinfowidget.cpp
    userinfowidget.h userinfowidget.cpp
    sessiondetailwidget.h sessiondetailwidget.cpp
    choosefrienddialog.h choosefrienddialog.cpp
    groupsessiondetailwidget.h groupsessiondetailwidget.cpp
    addfrienddialog.h addfrienddialog.cpp
    historymessagewidget.h historymessagewidget.cpp
    loginwidget.h loginwidget.cpp
    phoneloginwidget.h phoneloginwidget.cpp
    toast.h toast.cpp
    proto/base.proto proto/file.proto proto/friend.proto proto/gateway.proto proto/message_storage.proto proto/message_transmit.proto proto/notify.proto proto/speech_recognition.proto proto/user.proto
    model/datacenter.h model/datacenter.cpp
    network/netClient.h network/netClient.cpp
)

qt_add_protobuf(mimsclient PROTO_FILES ${PB_FILES})

target_link_libraries(mimsclient
    PRIVATE
        Qt::Core
        Qt::Widgets
)
target_link_libraries(mimsclient
    PRIVATE
        Qt6::Core
        Qt6::Widgets
        Qt6::Protobuf
        Qt6::Network
        Qt6::WebSockets
)

include(GNUInstallDirs)

install(TARGETS mimsclient
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET mimsclient
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
